function [Xnew Ynew off] = drawCursor(Task, X, Y, fb, off)
global pK pR pF
global mouseSize mouseThick PosTarget

switch Task
    case 1
        % Baseline trial
        Xnew = X;
        Ynew = Y;
    case 2
        % scaling trial
        Xnew = pK*X;
        Ynew = pK*Y;
    case 3
        % rotation trial
        Xnew = X*cos(pR) - Y*sin(pR);
        Ynew = X*sin(pR) + Y*cos(pR);
    case 4
        % flipping trial
        Xnew = -X;
        Ynew = Y;
end
if fb ~= 0 && off == 0;
	if fb == 1 || ( norm([Xnew, Ynew]) < PosTarget*fb )
		% Draw the cursor only if visual feedback is totally on (fb == 1)
		% or visual feedback is partially on (1> fb > 0) AND the cursor is
		% not beyond the distance between the target and center position
		% multiplied by fb
		cgpencol(1,1,1);
		cgpenwid(2);
		cgrect(Xnew, Ynew, mouseSize, mouseThick);
		cgrect(Xnew, Ynew, mouseThick, mouseSize);
	else
		% If the visual feedback is partially on (1> fb > 0) AND the cursor
		% is beyond the distance between the target and center position
		% multiplied by fb, then stop showing the cursor
		off = 1;
	end
end
cgflip(0,0,0);

return
